#ifndef __MATH_H__
#define __MATH_H__

const float HALF_REV = 0.5f;

float Sin(float x)
{
	const float INV_HALF_REV = 1.f / HALF_REV;
	float sign = int(x*INV_HALF_REV) % 2 == 0 ? 1 : -1;
	if (x < 0)
		sign = -sign;
	x = std::abs(std::fmod(x, HALF_REV));
	float xx = x*4 * (HALF_REV - x);
	return sign*xx*4 / ((5.f * HALF_REV * HALF_REV) - xx);
}

float Cos(float x)
{
	return Sin((0.5f * HALF_REV) + x);
}

#endif
